<?php

$dump_result = dump();

$unique_array = array_unique($dump_result);

$i = 1;
foreach($unique_array as $key)
{
	echo "INSERT INTO keyinfo (keyid,keytype,keyword,search_times) VALUES (".$i.",1,\"".$key."\",0);</br>";
	$i++;
}

function dump(){
	$con = mysql_connect("127.0.0.1","root","redhat");
	if (!$con)
	{
		die('Could not connect: ' . mysql_error());
	}

	mysql_select_db("kfcmenu", $con);
	mysql_query("set names utf8");

	$temp = "SELECT keyword FROM kfcmenu";
	$db_result = mysql_query($temp);

	$result = array();
	while($row = mysql_fetch_array($db_result))
	{
		$temp = explode("，", $row['keyword']);
		foreach($temp as $word){
			array_push($result,$word);
			/*$result = $result.$word."</br>";*/
		}
	}
	
	mysql_close($con);
	return $result;
}

?>